package team.szm.scd.service.interfaces;

import team.szm.scd.database.entity.Doctor;
import team.szm.scd.database.entity.User;

import javax.servlet.http.HttpSession;

public interface ILoginService {
    default boolean noUserAndNoDoctorLogin(HttpSession session) {
        return noUserLogin(session) && noDoctorLogin(session);
    }

    default boolean noUserLogin(HttpSession session) {
        return getLoginUser(session) == null;
    }

    default boolean noDoctorLogin(HttpSession session) {
        return getLoginDoctor(session) == null;
    }

    default User getLoginUser(HttpSession session) {
        return (User) session.getAttribute(User.USER_SESSION_STR);
    }

    default Doctor getLoginDoctor(HttpSession session) {
        return (Doctor) session.getAttribute(Doctor.DOCTOR_SESSION_STR);
    }
}
